<template>
  <!-- swiper3.x
  npm install swiper@3.4.1 --save
   -->
  <div class="swiper-container">
    <div class="swiper-wrapper">
      <div class="swiper-slide" v-for="item in imgList" :key="item">
        <img :src="item" />
      </div>
    </div>
    <div class="swiper-pagination"></div>
  </div>
</template>

<script>
import Swiper from "swiper";
import "swiper/dist/css/swiper.min.css";

export default {
  name: "Swiper",
  props: {
    imgList: {
      tyep: Array,
      default: () => [],
    },
  },
  mounted() {
      this.swiper = new Swiper(".swiper-container", {
        //速度
        observer: true, //修改swiper自己或子元素时，自动初始化swiper
        observeParents: true, //修改swiper的父元素时，自动初始化swiper
        autoplayDisableOnInteraction : false,   // 用户操作swiper之后，是否禁止autoplay
        speed: 1500,
        autoplay: 3000,
        centerInsufficientSlides: true,
        loop: true,
        pagination:  ".swiper-pagination",
      });
  },
};
</script>

<style scoped>
.swiper-container {
  width: 100%;
  height: 100%;
}
img {
  width: 100%;
}
.swiper-container >>> .swiper-pagination-bullet {
  opacity: 1;
  background: #fff;
}
.swiper-container >>> .swiper-pagination-bullet-active {
  opacity: 2;
  background: red;
}
</style>